import Mock from 'mockjs';
import setupMock, {
  successResponseWrap,
  failResponseWrap,
} from '@/utils/setup-mock';

import { MockParams } from '@/types/mock';
import { isLogin } from '@/utils/auth';


setupMock({
  setup() {

    //任务创详情
    Mock.mock(new RegExp('/anno/task$'), (model) => {
      return successResponseWrap({
        // 基本信息
        basicSetting: {   
          id: 1,
          createUserName: "创建人1",   //创建人
          createTime: 1668413652123,   //任务时间
          status: 1, //任务状态
          name: "任务名称1", //任务名称
          department: "1", //科室
          label: "1", //任务标签
          target: "1", //任务目标
          uses: "1", //任务用途
          discardCodeList: "1", // 废片原因 以,分隔
        },
        // 标注信息
        annoInfo: {
            defaultWindow: "默认窗宽窗位",      //默认窗宽窗位
            findings: true,        //是否展示检查所见
            diagnosis: true,       //是否展示诊断所得
            showYay: true,         //是否需要阴阳性
            showReport: true,       //是否需要图文报告
            imageLayout: "1",        //布局
            seriesFcList: [
              {
                fcId: 1,
                required: true,
              },
              {
                fcId: 2,
                required: false,
              },
            ],
        },
        lesionList: [
          {
            lesionValue: "CEREBROVASCULAR_SEGMENT",      //病灶编码
            color: "#110022",            //颜色
            toolValueList: ["ELLIPSE","RECTANGLE"],    //工具编码列表
            imageFcList:[
              {
                fcId: 1,
                required: true,
                name: "a医生",
              },
              {
                fcId: 2,
                required: false,
                name: "b医生",
              },
            ],
          }
        ],
        // 添加数据
        dataInfo: [
          {
            seriesUid: "1.2.124.113532.58efhaofuaufafhaiofaihfha.36179930", //序列号
            auxSeriesList: [], //辅助/配准序列号
            annoAreaList: [], //大图标注区域
          },
          {
            seriesUid: "1.2.124.113532.58efhaofuaufafhaiofaihfha.3617993012", //序列号
            auxSeriesList: [], //辅助/配准序列号
            annoAreaList: [], //大图标注区域
          }
        ],
    
        // 标注人员
        annoUserInfo: {
          beginDate: 1668413652123,
          endDate: 1668413652123,    
          remark: "任务备注1",         
          pubMethod: "2",      
          assignMethod: "1",      
          crossNum: 1,       
          annoUserList: [
            {
              companyId: "1",
              userList: ["1"]
            },
            {
              companyId: "1",
              userList: ["2"]
            }
          ]
        }
      })
    })

    


    //任务创建
    Mock.mock(new RegExp('/anno/task/create'), (model) => {
      return successResponseWrap({

      })
    })
    //任务编辑
    Mock.mock(new RegExp('/anno/task/update'), (model) => {
      return successResponseWrap({

      })
    })
    


    //单位列表
    // Mock.mock(new RegExp('/user/search'), (model) => {
    //   return successResponseWrap({
    //     total: 3,
    //     pages: 1,
    //     list: [
    //       {
    //         id: "1",        // 用户ID
    //         userName: "杏脉用户1",      // 用户名称
    //         mobile: "13112345678",    // 用户手机
    //         company: {
    //           id: "1",    //单位id
    //           name: "单位名称1"    //单位名称
    //         },   
    //       },
    //       {
    //         id: "2",        // 用户ID
    //         userName: "杏脉用户2",      // 用户名称
    //         mobile: "13212345678",    // 用户手机
    //         company: {
    //           id: "2",    //单位id
    //           name: "单位名称2"    //单位名称
    //         },   
    //       },
    //       {
    //         id: "3",        // 用户ID
    //         userName: "杏脉用户3",      // 用户名称
    //         mobile: "13312345678",    // 用户手机
    //         company: {
    //           id: "3",    //单位id
    //           name: "单位名称3"    //单位名称
    //         },   
    //       },
    //     ]
    //   })
    // })

    //单位列表
    Mock.mock(new RegExp('/api/company/list'), (model) => {
      return successResponseWrap({
        list: [
          {
            id: "1",        // 单位ID
            name: "云济",      // 名称
            remark: "备注1",    // 备注
            status: 1,    // 单位ID
          },
          {
            id: "2",        // 单位ID
            name: "杏脉医生",      // 名称
            remark: "备注2",    // 备注
            status: 1,    // 单位ID
          },
          {
            id: "3",        // 单位ID
            name: "复兴",      // 名称
            remark: "备注3",    // 备注
            status: 1,    // 单位ID
          }
        ]
      })
    })
    
    
    Mock.mock(new RegExp('/api/anno/task/series/import'), (model) => {
        //      seriesUid				String	Y	
        // 辅助/配准序列号		auxSeriesList				List(String)	N	 auxSeriess
        // 大图标注区域		annoAreaList				List(String)	N	  annoAreas
      return successResponseWrap({
        "seriesInfoList": [
          {
              "seriesUid": "1.3.12.2.1107.5.1.4.67342.30000017072001134283000040431",
              "hospCode": "0000001198",
              "bodyPart": "HEART",
              "modality": "CT",
              "studyDate": "2017-07-20",
              "studyUid": "1.2.826.0.1.3680043.2.461.9386868.2063509393",
              "fileType": "dcm",
              "age": 82,
              "sex": "M",
              "uploadTime": 1623859200000,
              "mainSeries": true,
              "studyFinding": null,
              "keyword": null,
              "resultTasks": [
              ],
              "auxSeriesList": [
                  "1.3.46.670589.33.1.63753838721776530200004.5182233319718410707"
              ],
              "annoAreaList": [
                  "{\"data\":{\"point1\":{\"x\":5268.898832281599,\"y\":5119.308660774672},\"point2\":{\"x\":7196.950134991458,\"y\":8210.839359807207}},\"version\":1}",
                  "{\"data\":{\"point1\":{\"x\":831.0565896867146,\"y\":365.664904341048},\"point2\":{\"x\":6016.849689816238,\"y\":7246.813525493768}},\"version\":1}"
              ],
              "assigned": null
          },
          {
              "seriesUid": "1.3.12.2.1107.5.1.4.73757.30000018080501060806100224850",
              "hospCode": "0000001198",
              "bodyPart": "HEART",
              "modality": "CT",
              "studyDate": "2018-08-10",
              "studyUid": "1.2.826.0.1.3680043.2.461.10176992.1383934869",
              "fileType": "dcm",
              "age": 56,
              "sex": "M",
              "uploadTime": 1626105600000,
              "mainSeries": false,
              "studyFinding": null,
              "keyword": null,
              "resultTasks": [],
              "auxSeriesList": [
                  "1.2.840.113619.6.80.114374079232140.100813.1542892813427.1",
                  "1.3.12.2.1107.5.1.4.73133.30000013100702300379600081323"
              ],
              "annoAreaList": [
                  "{\"data\":{\"point1\":{\"x\":5268.898832281599,\"y\":5119.308660774672},\"point2\":{\"x\":7196.950134991458,\"y\":8210.839359807207}},\"version\":1}",
              ]
          }
        ]
      });
    });


    Mock.mock(new RegExp('/api/config/formComponent/read'), (model) => {
      return successResponseWrap({
        "tagList": [
          {
            "id": 45,
            "category": "COMPONENT",
            "text": "骨折"
          }
        ],
        "createUserId": 5196,
        "code": "1076",
        "data": "[{\"code\":\"1\",\"text\":\"肋骨\",\"child\":[{\"code\":\"1\",\"text\":\"1\"},{\"code\":\"2\",\"text\":\"2\"},{\"code\":\"3\",\"text\":\"3\"},{\"code\":\"4\",\"text\":\"4\"},{\"code\":\"5\",\"text\":\"5\"},{\"code\":\"6\",\"text\":\"6\"},{\"code\":\"7\",\"text\":\"7\"},{\"code\":\"8\",\"text\":\"8\"},{\"code\":\"9\",\"text\":\"9\"},{\"code\":\"10\",\"text\":\"10\"},{\"code\":\"11\",\"text\":\"11\"},{\"code\":\"12\",\"text\":\"12\"},{\"code\":\"13\",\"text\":\"13\"}]},{\"code\":\"2\",\"text\":\"胸骨\",\"child\":[{\"code\":\"1\",\"text\":\"左\"},{\"code\":\"2\",\"text\":\"右\"}]}]",
        "editable": false,
        "parameter": "{\"isdefault\":false}",
        "name": "骨折部位",
        "id": 1076,
        "type": "child_select"
      })
    });


    Mock.mock(new RegExp('/api/config/formComponent/query'), (model) => {
      const list = getComponentList();
      const ids = JSON.parse(model.body).ids;
      const data = ids.map((id: number) => {
        const index = list.findIndex(item => item.id === id);
        return list[index];
      })
      return successResponseWrap({
        list: data || []
      })
    });


    Mock.mock(new RegExp('/api/config/formComponent/search'), () => {
      return successResponseWrap({
        total: 12,
        pages: 1,
        list: getComponentList(),
      })
    });

    function getComponentList() {
      return [
        {
          id: 1,
          name: "备注医生1",
          value: "1",
          type: "text", //text
          parameter: "组件参数",
          data: "",
          createTime: "2022-10-10",
          updateTime: "2022-10-10",
        },
        {
          id: 2,
          name: "备注医生2",
          value: "2",
          type: "text",
          parameter: "组件参数",
          data: "",
          createTime: "2022-10-10",
          updateTime: "2022-10-10",
        },
        {
          id: 3,
          name: "备注医生3",
          value: "1",
          type: "text",
          parameter: "组件参数",
          data: "",
          createTime: "2022-10-10",
          updateTime: "2022-10-10",
        },
        {
          id: 4,
          name: "备注医生4",
          value: "1",
          type: "text",
          parameter: "组件参数",
          data: "",
          createTime: "2022-10-10",
          updateTime: "2022-10-10",
        },
        {
          id: 5,
          name: "备注医生5",
          value: "1",
          type: "text",
          parameter: "组件参数",
          data: "",
          createTime: "2022-10-10",
          updateTime: "2022-10-10",
        },
        {
          id: 6,
          name: "备注医生6",
          value: "1",
          type: "text",
          parameter: "组件参数",
          data: "",
          createTime: "2022-10-10",
          updateTime: "2022-10-10",
        },
        {
          id: 7,
          name: "备注医生7",
          value: "1",
          type: "text",
          parameter: "组件参数",
          data: "",
          createTime: "2022-10-10",
          updateTime: "2022-10-10",
        },
        {
          id: 8,
          name: "备注医生8",
          value: "1",
          type: "text",
          parameter: "组件参数",
          data: "",
          createTime: "2022-10-10",
          updateTime: "2022-10-10",
        },
        {
          id: 9,
          name: "备注医生9",
          value: "1",
          type: "text",
          parameter: "组件参数",
          data: "",
          createTime: "2022-10-10",
          updateTime: "2022-10-10",
        },
        {
          id: 10,
          name: "备注医生10",
          value: "1",
          type: "text",
          parameter: "组件参数",
          data: "",
          createTime: "2022-10-10",
          updateTime: "2022-10-10",
        },
        {
          id: 11,
          name: "备注医生11",
          value: "1",
          type: "text",
          parameter: "组件参数",
          data: "",
          createTime: "2022-10-10",
          updateTime: "2022-10-10",
        },
        {
          id: 12,
          name: "备注医生12",
          value: "1",
          type: "text",
          parameter: "组件参数",
          data: "",
          createTime: "2022-10-10",
          updateTime: "2022-10-10",
        },


      ]
    }

  },
});
